package com.dao;

import java.util.List;

import com.entity.Article;
import com.util.Page;
/**
 * @author tiger
 *
 */
public class ArticleDao extends BaseDAO {
	
	/**
	 * 保存
	 * @param article
	 * @return
	 */
	public boolean saveArticle(Article article){
		return this.saveObject(article);
	}
	
	/**
	 * 保存
	 * @param article
	 * @return
	 */
	public boolean updateArticle(Article article){
		return this.updateObject(article, "where id=?",article.getId());
	}
	
	/**
	 * 查询所有分类 
	 * @return
	 * @throws Exception
	 */
	public List findArticleList() throws Exception{
		return this.queryObject(Article.class);
	}
	
	/**
	 * 查询单个对象
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Article findArticleById(String id) throws Exception{
		Article article = null;
		article = (Article) this.queryByObjectId(Article.class, "where :id=?",id);
		return article;
	}	
	
	/**
	 * 删除多个
	 * @param ids
	 * @return
	 */
	public boolean delArticleByIds(String ids){
		String sql = "delete from Article where id in ("+ids+")";
		return this.executeUpdate(sql);
	}
	
	/**
	 * 
	 * @param article
	 * @return
	 */
	public boolean delArticle(Article article){
		return this.deleteObject(article);
	}
	
	/**
	 * 按分页查询
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public Page findbyPage(Page page) throws Exception{
		return this.queryObjectForPage(Article.class, page);
	}
}
